import { ref, computed, reactive } from 'vue'
import { defineStore } from 'pinia'

export const useToolStore = defineStore('tool', () => {
  const serverHost = ref('https://sges.yangke.site') // 结尾不能包含'/'
  const serverPort = ref('5001')
  const appName = ref('template')

  const currentUsername = ref<string>('未登录')
  const currentUserEmail = ref<string>('')
  const money = ref(0)
  const vip = ref(0)
  const lastLogin = ref('')
  const isLogin = ref(false)
  const lastTickTime = ref('')
  const accountStatus = computed(() => {
    if (money.value > 0) {
      return '账户正常'
    } else if (money.value < 0) {
      return '积分过低，请及时充值'
    } else if (money.value < -15) {
      return '请充值后使用'
    }
  })
  const processing = ref(false) // 是否有进程在执行
  const existsSchedule = ref(false) // 是否存在定时任务

  return {
    serverHost,
    serverPort,
    currentUsername,
    currentUserEmail,
    isLogin,
    money,
    lastLogin,
    vip,
    lastTickTime,
    accountStatus,
    processing,
    existsSchedule,
    appName
  }
})